/**
 * 
 */
package com.wgo.precise.client.common.session;

import java.net.URL;

import com.wgo.bpot.client.session.LightSession;
import com.wgo.bpot.common.removeme.Persistent;
import com.wgo.precise.service.PreciseService;

/**
 * @author peide3
 *
 */
public class PreciseSessionImpl extends LightSession implements PreciseSession {

	private static final String PRECISE_SERVLET_RELATIVE_PATH = "/preciseservice";

	private PreciseService preciseService;

	/**
	 * @param arg0
	 * @param arg1
	 */
	public PreciseSessionImpl(URL remoteUrl, Class rootConceptClass) {
		super(remoteUrl, rootConceptClass);
		preciseService = new PreciseServiceClientImpl(remoteUrl, PRECISE_SERVLET_RELATIVE_PATH);
	}

	/**
	 * @see com.wgo.precise.client.common.session.PreciseSession#exportToXml(com.wgo.precise.client.common.session.PreciseSession.ObjectHolder)
	 */
	public void exportToXml(ObjectHolder<byte[]> objectHolder) {
		objectHolder.setObject(preciseService.exportToXml());
	}

	/**
	 * @see com.wgo.precise.client.common.session.PreciseSession#getPdf(com.wgo.bpot.common.removeme.Persistent, com.wgo.precise.client.common.session.PreciseSession.ObjectHolder)
	 */
	public void getPdf(Persistent persistent, ObjectHolder<byte[]> objectHolder) {
		objectHolder.setObject(preciseService.getPdf(persistent.getClass().getInterfaces()[0], persistent.getDbId()));
	}

	/**
	 * @see com.wgo.precise.client.common.session.PreciseSession#importFromXml(java.io.File, com.wgo.precise.client.common.session.PreciseSession.ObjectHolder)
	 */
	public void importFromXml(byte[] preciseXmlFile, ObjectHolder<Boolean> objectHolder) {
		objectHolder.setObject(preciseService.importFromXml(preciseXmlFile));
	}


	
}

